/**     
 * @Title: Swagger2Config.java   
 * @Package me.swagger2.config   
 * @Description: TODO
 * @author weiwei 
 * @date 2018年3月29日 上午10:54:21   
 * @version V1.0     
 */
package me.swagger2.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @ClassName: Swagger2Config
 * @Description: TODO
 * @author weiwei
 * @date 2018年3月29日 上午10:54:21
 * 
 */
@EnableSwagger2
@Configuration
public class Swagger2Config {

	@Bean
	public Docket createRestApi() {
		return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.basePackage("me.swagger2.controller"))
				.paths(PathSelectors.any()).build();
	}

	private ApiInfo apiInfo() {
		return new ApiInfoBuilder().title("SpringBoot 中使用 Swagger2 构建Restful APIs").description("测试")
				.contact(new Contact("xaoyaoyao", "https://gitee.com/xaoyaoyao/events", "xaoyaoyao@aliyun.com")).version("1.0").build();
	}
}
